mod token;

use token::tokenize;

// use pest_derive::Parser;
use std::{env, fs};

// #[derive(Parser)]
// #[grammar = "../sysy.pest"]
// struct SysYLexer;

fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() < 2 {
        eprintln!("Usage: {} <filename>", args[0]);
        std::process::exit(1);
    }

    let filename = &args[1];

    println!("{}", filename);

    let content = fs::read_to_string(filename).expect("Failed to read file");

    let tokens = tokenize(&content);

    for token in tokens {
        eprintln!("{:?} {} at Line {}.", token.token, token.value, token.line);
    }
}
